package com.docmanage.common.config;

import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Minio 配置信息
 *
 * @author ruoyi
 */
@Configuration
@ConfigurationProperties(prefix = "minio")
public class MinioConfig
{
    /**
     * 服务地址
     */
    private static String url;

    /**
     * 用户名
     */
    private static String access;

    /**
     * 密码
     */
    private static String secret;

    /**
     * 存储桶名称
     */
    private static String bucket;
    /**
     * cdn域名
     */
    private static String cdn;

    public static String getUrl()
    {
        return url;
    }

    public void setUrl(String url)
    {
        MinioConfig.url = url;
    }

    public static String getAccess()
    {
        return access;
    }

    public void setAccess(String access)
    {
        MinioConfig.access = access;
    }

    public static String getSecret()
    {
        return secret;
    }

    public void setSecret(String secret)
    {
        MinioConfig.secret = secret;
    }

    public static String getBucket()
    {
        return bucket;
    }

    public void setBucketName(String bucket)
    {
        MinioConfig.bucket = bucket;
    }

    public static String getCdn()
    {
        return cdn;
    }

    public void setCdn(String cdn)
    {
        MinioConfig.cdn = cdn;
    }

    @Bean
    public MinioClient getMinioClient()
    {
        return MinioClient.builder().endpoint(url).credentials(access, secret).build();
    }
}
